/* eslint-disable no-shadow */
export function count({ search }) {
  return RSocket.rr({
    route: 'busorders.count',
    args: { search },
  });
}

export function search({ search, pg }) {
  return RSocket.rs({
    route: 'busorders',
    args: { search, pg, sort: ['upDate;desc'] },
  });
}

export function ordersSearchCount({ search }) {
  return RSocket.rr({
    route: 'orders.search.count',
    args: { search: { ...search, orderType: 3 } },
  });
}

export function ordersSearch({ search, pg }) {
  return RSocket.rs({
    route: 'orders.search',
    args: { search: { ...search, orderType: 3 }, pg, sort: ['upDate;desc'] },
  });
}

export function get(id) {
  return RSocket.rr({
    route: `busorders.${id}`,
  });
}

export function update(order) {
  return RSocket.rr({
    route: 'busorders.update',
    data: order,
  });
}

export function create(order) {
  return RSocket.rr({
    route: 'services.order.create',
    data: order,
  });
}

/**
 * 手动同步巴士状态
 */
export function syncBusOrder() {
  return RSocket.rr({
    route: 'services.update.ticket.status',
  });
}

/**
 * 按手机号搜索用户
 * @param {*} mobile 手机号
 * @returns 用户列表
 */
export function usersForMobile(mobile) {
  return RSocket.rs({
    route: 'inetusers',
    args: { search: { keyword: mobile } },
  });
}

/**
 * 按手机号获取用户
 * @param {string} mobile 手机号
 */
export function userForMobile(mobile) {
  return RSocket.rr({
    route: 'inetusers.mobile',
    args: { mobile },
  });
}

/**
 *
 * @param {*} param0
 * @returns
 */
export function partners({ search, page }) {
  return RSocket.rs({
    route: 'partners',
    args: {
      search,
      pg: { page, sort: ['partnerInfo.registerTime;desc'] },
    },
  });
}

/**
 * 根据不同方向查询城市信息 0：开始城市，1：结束城市
 */
export function getCities({ type, city = '' }) {
  return RSocket.rs({
    route: `routes.${type}.region`,
    args: {
      city,
      pg: { size: 10000 },
    },
  });
}

/**
 * 查询班次
 * @param {} param0
 * @returns
 */
export function getShifts({
  departureDate,
  originId,
  destinationId,
  isReturn,
  currencyId,
  priceType,
}) {
  return RSocket.rs({
    route: 'services.shift',
    data: {
      departureDate,
      originId,
      destinationId,
      isReturn,
      currencyId,
      priceType,
    },
  });
}

/**
 * 获取班次信息
 * @param {*} param0
 * @returns
 */
export function getBcInfo({
  runId,
  originId,
  destinationId,
  currencyId,
  isReturn,
  priceType,
}) {
  return RSocket.rr({
    route: 'services.bc.info',
    data: {
      runId,
      originId,
      destinationId,
      currencyId,
      isReturn,
      priceType,
    },
  });
}

/**
 * @func 日志流水分页条件查询
 * @param {}
 */
export function getLogs({ search }) {
  return RSocket.rs({
    route: 'logs',
    args: {
      search,
      pg: { page: 0, size: 100, sort: ['ts;desc'] },
    },
  });
}

/**
 * @func 获取订单退款数据
 * @param {}
 */
export function getRefund(id) {
  return RSocket.rs({
    route: `orders.${id}.get.refund`,
  });
}

/**
 * 订单发起申请退款
 * @param {*} id 订单id
 * @param {*} data 请求数据
 * @returns true
 */
export function orderSponsorRefund(id, data, args) {
  return RSocket.rr({
    route: `orders.${id}.application.refund`,
    args: {
      ...args,
    },
    data: [
      data,
    ],
  });
}

/**
 * 订单发起线下支付
 * @param {*} data 请求数据
 * @returns true
 */
export function orderOfflineSubmit(data) {
  return RSocket.rr({
    route: 'pay.offline-payments.submit',
    data: {
      ...data,
    },
  });
}

/**
 * 订单发起线下支付 后端中间件
 * @param {*} data 请求数据
 * @returns true
 */
export function orderCreateOffline(data) {
  return RSocket.rr({
    route: 'cbv.offline.add.refund',
    data: {
      ...data,
    },
  });
}

/**
 * 获取该车票下的订单信息
 * @param {*} id 订单id
 * @returns true
 */
export function getIdRefund(id) {
  return RSocket.rs({
    route: `orders.${id}.get.refund`,
  });
}

/**
 * 获取该车票下的订单信息
 * @param {*} id 订单id
 * @returns true
 */
export function getOrderTicket({ search, pg }) {
  return RSocket.rs({
    route: 'cbv.applications',
    args: {
      search: {
        ...search,
        orderType: '3',
      },
      pg,
    },
  });
}

/**
 * 获取该车票下的订单信息
 * @param {*} id 订单id
 * @returns true
 */
export function getOrderTicketCount({ search }) {
  return RSocket.rr({
    route: 'cbv.applications.count',
    args: {
      search: {
        ...search,
        orderType: '3',
      },
    },
  });
}

/**
 * 取消订单中的申请退款
 * @param {*} data 请求参数
 * @returns true
 */
export function orderCancelRefund(data) {
  return RSocket.rr({
    route: 'orders.cancel.refund',
    args: {
      ...data,
    },
  });
}

/**
 * 提交订单中的申请退款
 * @param {*} data 请求参数
 * @returns true
 */
export function orderCommitRefund(data) {
  return RSocket.rr({
    route: 'orders.commit.refund',
    args: {
      ...data,
    },
  });
}

/**
 * 修改订单中的申请退款
 * @param {*} data 请求参数
 * @returns true
 */
export function orderRefundUpdate(data) {
  return RSocket.rr({
    route: 'cbv.applications.update',
    data: {
      ...data,
    },
  });
}

/**
 * 修改订单中的申请退款
 * @param {*} args 请求参数
 * @returns true
 */
export function getOrderRefundTicket(args) {
  return RSocket.rs({
    route: 'orders.get.refund.ticket',
    args: {
      ...args,
    },
  });
}

/**
 * 查询分账方
 * @param {*} orderId 订单id
 * @returns true
 */
export function getAccount(orderId) {
  return RSocket.rs({
    route: `orders.${orderId}.account.info`,
    args: {
      directRoute: false,
    },
  });
}

/**
 * 获取该订单所有车票对应已退款金额
 * @param {*} orderId 订单id
 * @returns true
 */
export function getTicketRefunds(orderId) {
  return RSocket.rr({
    route: `cbv.applications.${orderId}.tickets.refund.amount`,
  });
}

/**
 * 报备车票
 * @param {*} orderId 订单id
 * @returns true
 */
export function reportTicket(data) {
  return RSocket.rr({
    route: 'orders.report.ticket',
    args: { ...data },
  });
}

/**
 * 获取包车订单数据
 * @param {*} id
 * @returns
 */
export function getCcOrderInfo(id) {
  return RSocket.rr({
    route: `ccorders.${id}`,
  });
}

/**
 * 获取订单优惠信息
 * @param {*} id
 * @returns
 */
export function getOrderDiscountInfo(args) {
  return RSocket.rs({
    route: 'cbv.applications.order.discount.info',
    args: {
      ...args,
    },
  });
}

/**
 * 获取接待打标列表
 * @param {*} search
 * @returns
 */
export function getManagersMark({ search }) {
  return RSocket.rs({
    route: 'cbv.managers.reception.mark.info',
    args: {
      search,
      pg: {
        page: 0,
        size: 99,
      },
    },
  });
}

/**
 * 查询公司
 * @param {*} search
 * @returns
 */
export function getCompanys({ search }) {
  return RSocket.rs({
    route: 'companys',
    args: {
      search,
      pg: {
        page: 0,
        size: 99,
      },
    },
  });
}

/**
 * 查询改签父订单
 * @param {*} search
 * @returns
 */
export function getChangeOrder(data) {
  return RSocket.rs({
    route: 'orders.change.associated.order',
    data: [...data],
  });
}

/**
 * 获取收款方
 */
export function getOrderPayee(args) {
  return RSocket.rr({
    route: 'pay.trans.payee',
    args,
  });
}
